<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="js/jquery-1.11.0.min.js"></script>

</head>
<body>
<div>
  <form id="form">
    <p id="caozuo">转账操作</p> <br>
    <!--  //用户自己判断转一类卡还是二类卡-->
    请选择转账账户类型：<select id="accountType">
    <option>一类卡</option>
    <option>二类卡</option>
  </select><br>
    收款人姓名：<input type="text" id="name" name="name" placeholder="请输入收款人姓名"> <br>
    收款人卡号：<input type="text" id="id" name="id" placeholder="请输入收款人卡号"> <br>
    支付密码：<input type="password" id="password" name="password"placeholder="请输入支付密码"> <br>
    转账金额：<input type="text" id="money" name="money"placeholder="请输入转账金额"><br>
    <span style="color: brown" id="balance"></span><br>
    <input type="button" id="zhuanzhangBtn" value="转账">
  </form>
</div>
<table width="100%" id="shouye">
  <tr>
    <td align="center"><a href="/airong/index.html">首页</a></td>
    <!--    <td align="center"><a href="#"><input type="button" id="lc" value="理财"></a></td>-->
    <td align="center"><a href="" id="lc">理财</a></td>
    <td align="center"><a href="/airong/personalCenter.html">我的</a></td>

  </tr>
</table>
</body>
<script>

  let balance = getUrlParms("yue")
  $("#balance").html("余额："+balance)

  $("#zhuanzhangBtn").click(function (){
    let account = getUrlParms("account")
    let id2 = getUrlParms("id")
    let type = $("#accountType").val()
    let name = $("#name").val()
    let id = $("#id").val()
    let password = $("#password").val()
    let money = $("#money").val()
    let url2 = "/airong/card?action=zhuanzhang"
    let url1 = "/airong/card?action=zhuanzhang1"
    let params = {id2,type,name,id,password,money}
    if (account == "2"){
      $.post(url2,params,function (data){
        if (data === "\"lowBalance\""){
          alert("余额不足")
        }else if (data === "\"false\""){
          alert("查无此卡")
        }else if (data === "\"falsePwd\""){
          alert("密码错误")
        }else if (data === "\"balanceNull\""){
          alert("请填写转账金额")
        } else {
          let c = confirm("确定要转账"+money+"元吗")
          if (c == true){
            alert("转账成功")
            location.href = "account.html"
          }else {
            alert("转账失败")
          }
        }
      },"text")
    }else {
      $.post(url1,params,function (data){
        if (data === "\"lowBalance\""){
          alert("余额不足")
        }else if (data === "\"false\""){
          alert("查无此卡")
        }else if (data === "\"falsePwd\""){
          alert("密码错误")
        }else if (data === "\"balanceNull\""){
          alert("请填写转账金额")
        } else {
          let c = confirm("确定要转账"+money+"元吗")
          if (c == true){
            alert("转账成功")
            location.href = "account.html"
          }else {
            alert("转账失败")
          }
        }
      },"text")
    }

  })
  function getUrlParms (name) {
    let url = window.location.href;//获取请求进来的完整url
    let tstr = url.substring(url.indexOf('?') + 1).split('&');//先截取url的?后面的参数部分，在根据&分割成参数数组
    let result = {};
    tstr.forEach((item) => {
      let res = item.split('=');//res为type,my-component1.vue。  res[0]为type，res[1为]my-component1.vue
      result[res[0]] = res[1];//构造成键值对形式 res[0]为键，res[1]为值 例：type: "my-component1.vue"
    });
    return result[name];//通过键取值
  };
  let urll = "/airong/cc?action=getSessionID";
  let paramsl = {}
  $.get(urll,paramsl,function (sessionID){
    document.getElementById('lc').href= "products.html?uid="+sessionID;
  },"text")

</script>
<style>
  div {

    width: 100%;
    text-align: center;
  }
  input{
    padding: 10px;
    margin: 10px;
    text-align: left;
  }
  #shouye{
    position: absolute;
    top: 600px;
    padding: 5px;
    margin: 4px;
    background-color: bisque;
    font-size: 20px;
    text-align: center;
    z-index: 1;
  }

</style>
</html>